<?php session_start(); ?>
<link rel="stylesheet" type="text/css" href="../css2/css.css" media="screen" title="COLABORE Hotelaria">
<body onload="javascript:document.forms[0].pnome.focus();">
<?php
include"../admin/conexao.jsp";
$nome_autor=strtoupper(trim($_POST["pnome"]));


if($_GET[cont]==2){
   require_once"../funcoes/bibl_autor.jsp";
   setAutor(0,$nome_autor);

   $sql0="select cod_autor, nome_autor from bibl_autores where nome_autor = '$nome_autor'";
   $linha0=$_SESSION['ADOCnn']->Execute("$sql0");

   $codigo = $linha0->fields[0];
   $nome   = $linha0->fields[1];

   echo"<BR><BR><a href='javascript:void(0);' onClick=\"javascript:window.opener.setCodAutor('$codigo-'); javascript:window.opener.setNomeAutor('$nome');\"><img src='../images/btn_adicionar.gif' border='0'></a> $nome<br>\n";
   


}elseif($_GET[cont]==1){


   $sql0="select count(cod_autor) from bibl_autores where nome_autor like '%$nome_autor%'";
   $linha0=$_SESSION['ADOCnn']->Execute("$sql0");
   if($linha0->fields[0] > 0){

           $sql="select cod_autor, nome_autor from bibl_autores where nome_autor like '%$nome_autor%'";
           $linha=$_SESSION['ADOCnn']->Execute("$sql");
           $n=1;
           echo"<h2>Resultado da Busca:</h2><table>";
	if($linha->RecordCount() != 0 ){
	while(!$linha->EOF){      
              $codigo = $linha->fields[0];
              $nome =trim($linha->fields[1]);

              echo"<tr><td><a href='javascript:void(0);' onClick=\"javascript:window.opener.setCodAutor('$codigo-'); javascript:window.opener.setNomeAutor('$nome');\"><img src='../images/btn_adicionar.gif' border='0'></a></td><td> $n ) $nome</td></tr>\n";
              $n++;
 		$linha->MoveNext();
		}                 
           }
           echo"</table>";
           
    echo"<br><u>Caso n&atilde;o seja algum dos autores acima, deseja cadastr&aacute;-lo? </u><BR>
           <form method='POST' action='midia_bibl_autores.jsp?cont=2' autocomplete='off'>
           Nome Autor:<BR>
           <input type='text' size='20' maxlength='50' name='pnome' value='$nome_autor'>
           <input type='submit' value='cadastrar'>
           </form><BR>
           ";

   }else{
   
           echo"<u>Autor: <b>$nome_autor</b> n&atilde;o foi encontrado, deseja cadastr&aacute;-lo?</u><BR>
           <form method='POST' action='midia_bibl_autores.jsp?cont=2' autocomplete='off'>
           Nome Autor:<BR>
           <input type='text' size='20' maxlength='50' name='pnome' value='$nome_autor'>
           <input type='submit' value='cadastrar'>
           </form><BR>
           ";
   
            /*
             echo"
         <form method='POST' action='index.jsp?atualiza=1&tb=5' autocomplete='off'>
         Nome Autor:<BR>
         <input type='hidden' name='pcodigo' value='$codigo'>
         <input type='text' size='20' maxlength='50' name='pnome' value='$nome'>
         <input type='submit' value='alterar'>
         </form>
         ";
         */
    }
}else{
      echo"<form method='POST' action='midia_bibl_autores.jsp?cont=1'  autocomplete='off'>
      Nome Autor:<BR>
     <input type='text' size='20' maxlength='50' name='pnome'> exemplo: Machado <BR>
     <input type='submit' value='Pesquisar'>
     </form>";
}

?>
<hr>
			  <div id='topbar' style='position:absolute; top:23px; left:80%; visibility: hidden; z-index: 100;'>
               	 <a href='javascript:window.history.go(-1)'><img src='../images/btn_voltar2.gif' width='110' height='29' border='0'></a>
				 <a href='javascript:window.close()'><img src='../images/btn_fechar2.gif' width='110' height='29' border='0'></a>
			   </div>

<script type="text/javascript">


var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 340 //set x offset of bar in pixels
var startY = 100 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}

function staticbar(){
	barheight=document.getElementById("topbar").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("topbar");
	stayTopLeft();
}

if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar
</script>

			   
